import Vue from 'vue'
import VueRouter from 'vue-router'

import USER from '../views/USER.vue'
import ADMIN from '../views/ADMIN.vue'
import IndexContainer from '../components/USER/Index/IndexContainer.vue'
import ProductcenterContainer from '../components/USER/Productcenter/ProductcenterContainer.vue'
import Product from '../components/USER/common/Product.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/user',
    component: USER,
    children: [
      {
        name: 'index',
        path: '/user/index',
        components: {
          IndexContainer
        }
      },
      { path: '/user', redirect: '/user/index' },
      {
        name: 'productcenter',
        path: '/user/productcenter/:platformId/:categoryId/:page',
        components: {
          ProductcenterContainer
        }
      },
      {
        name: 'product',
        path: '/user/product/:id',
        components: {
          Product
        }
      }
    ]
  },
  { path: '/', redirect: '/user' },
  {
    path: '/admin',
    component: ADMIN
  }
]

const router = new VueRouter({
  routes
})

export default router
